﻿@inherits Website.AppView<Website.Models.HomeVo[]>

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>气死人</title>
    <script src="/Content/jquery.min.js"></script>
    <script>
        $(function() {
            $(".btnJiaru")
                .click(function() {
                    $.post("/togame",
                        { name: $("#txtName").val(), gid: $(this).closest("tr").attr("gid") },
                        function(data) {
                            if (data.ex) {
                                alert(data.ex);
                            } else {
                                location.href = "/game/" + data;
                            }
                        });
                });
            $("#btnCreateNew").click(function() {
                $.post("/newgame",
                    { name: $("#txtName").val(), gname: $("#txtGName").val() },
                    function(data) {
                        if (data.ex) {
                            alert(data.ex);
                        } else {
                            location.href = "/game/" + data;
                        }
                    });
            });
        });
    </script>
</head>
<body>
<div>
    玩家名称：<input type="text" style="width: 200px" id="txtName" />
</div>
<div>
    <input type="button" value="创建新游戏" id="btnCreateNew"/><input id="txtGName"/>
</div>
<table>
    <thead>
    <tr>
        <td>名称</td>
        <td>人数</td>
        <td>状态</td>
        <td>开始时间</td>
        <td>&nbsp;</td>
    </tr>
    </thead>
    <tbody>
    @foreach (var item in Model)
    {
        <tr gid="@item.Id">
            <td>@item.Name</td>
            <td>@item.Count</td>
            @if (item.Started)
            {
                <td style="color: red">已开始</td>
                <td>@item.StartTime</td>
            }
            else
            {
                <td>未开始</td>
                <td>未开始</td>
            }
            <td>
                <a class="btnJiaru" href="javascript:;">加&nbsp;入</a>
            </td>
        </tr>
    }
    </tbody>
</table>
</body>
</html>
